package com.sjz.bookmark.util;

import com.intellij.ide.bookmarks.Bookmark;
import com.sjz.bookmark.mysql.BookmarkGroupNode;

import javax.swing.*;
import javax.swing.tree.DefaultTreeCellRenderer;
import java.awt.*;

public class BookmarkTreeCellRenderer extends DefaultTreeCellRenderer {
    @Override
    public Component getTreeCellRendererComponent(JTree tree, Object value,
                                                  boolean sel, boolean expanded, boolean leaf, int row, boolean hasFocus) {
        super.getTreeCellRendererComponent(tree, value, sel, expanded, leaf, row, hasFocus);
        
        if (value instanceof BookmarkItemNode) {
            Bookmark bookmark = ((BookmarkItemNode) value).getBookmark();
            setIcon(getIconForBookmark(bookmark));
        } else if (value instanceof BookmarkGroupNode) {
            setIcon(getIconForGroup());
        }
        
        return this;
    }

    private Icon getIconForGroup() {
        return null;
    }

    private Icon getIconForBookmark(Bookmark bookmark) {
        // 根据书签类型返回不同图标
        return null;
    }
}